<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=0.8"/><title>16.1&nbsp;基于模式的宏</title><link rel="stylesheet" type="text/css" href="scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="racket.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-racket.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><script type="text/javascript" src="manual-racket.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Racket&#25351;&#21335;</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="intro.html" class="tocviewlink" data-pltdoc="x">&#27426;&#36814;&#26469;&#21040;Racket!</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="to-scheme.html" class="tocviewlink" data-pltdoc="x">Racket&#27010;&#35201;</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="datatypes.html" class="tocviewlink" data-pltdoc="x">&#20869;&#32622;&#30340;&#25968;&#25454;&#31867;&#22411;</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="scheme-forms.html" class="tocviewlink" data-pltdoc="x">&#34920;&#36798;&#24335;&#21644;&#23450;&#20041;</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="define-struct.html" class="tocviewlink" data-pltdoc="x">&#31243;&#24207;&#21592;&#23450;&#20041;&#30340;&#25968;&#25454;&#31867;&#22411;</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="modules.html" class="tocviewlink" data-pltdoc="x">&#27169;&#22359;</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">&#21512;&#32422;</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="i_o.html" class="tocviewlink" data-pltdoc="x">&#36755;&#20837;&#21644;&#36755;&#20986;</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="regexp.html" class="tocviewlink" data-pltdoc="x">&#27491;&#21017;&#34920;&#36798;&#24335;</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">&#24322;&#24120;&#19982;&#25511;&#21046;</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="for.html" class="tocviewlink" data-pltdoc="x">&#36845;&#20195;&#21644;&#25512;&#23548;</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">&#27169;&#24335;&#21305;&#37197;</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="classes.html" class="tocviewlink" data-pltdoc="x">&#31867;&#21644;&#23545;&#35937;</a></td></tr><tr><td align="right">14&nbsp;</td><td><a href="units.html" class="tocviewlink" data-pltdoc="x">&#21333;&#20803;</a></td></tr><tr><td align="right">15&nbsp;</td><td><a href="reflection.html" class="tocviewlink" data-pltdoc="x">&#21453;&#23556;&#21644;&#21160;&#24577;&#27714;&#20540;</a></td></tr><tr><td align="right">16&nbsp;</td><td><a href="macros.html" class="tocviewselflink" data-pltdoc="x">&#23439;</a></td></tr><tr><td align="right">17&nbsp;</td><td><a href="languages.html" class="tocviewlink" data-pltdoc="x">&#21019;&#36896;&#35821;&#35328;</a></td></tr><tr><td align="right">18&nbsp;</td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">&#24182;&#21457;&#19982;&#21516;&#27493;</a></td></tr><tr><td align="right">19&nbsp;</td><td><a href="performance.html" class="tocviewlink" data-pltdoc="x">&#24615;&#33021;</a></td></tr><tr><td align="right">20&nbsp;</td><td><a href="parallelism.html" class="tocviewlink" data-pltdoc="x">&#24182;&#34892;</a></td></tr><tr><td align="right">21&nbsp;</td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">&#36816;&#34892;&#21644;&#21019;&#24314;&#21487;&#25191;&#34892;&#31243;&#24207;</a></td></tr><tr><td align="right">22&nbsp;</td><td><a href="More_Libraries.html" class="tocviewlink" data-pltdoc="x">&#26356;&#22810;&#30340;&#24211;</a></td></tr><tr><td align="right">23&nbsp;</td><td><a href="dialects.html" class="tocviewlink" data-pltdoc="x">Racket&#21644;Scheme&#30340;&#26041;&#35328;</a></td></tr><tr><td align="right">24&nbsp;</td><td><a href="other-editors.html" class="tocviewlink" data-pltdoc="x">&#21629;&#20196;&#34892;&#24037;&#20855;&#21644;&#20320;&#30340;&#32534;&#36753;&#22120;&#36873;&#25321;</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9660;</a></td><td>16&nbsp;</td><td><a href="macros.html" class="tocviewlink" data-pltdoc="x">&#23439;</a></td></tr></table><div class="tocviewsublist" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">16.1&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">&#22522;&#20110;&#27169;&#24335;&#30340;&#23439;</a></td></tr><tr><td align="right">16.2&nbsp;</td><td><a href="proc-macros.html" class="tocviewlink" data-pltdoc="x">&#36890;&#29992;&#23439;&#36716;&#21270;&#22120;</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_2&quot;);">&#9658;</a></td><td>16.1&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">&#22522;&#20110;&#27169;&#24335;&#30340;&#23439;</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_2"><table cellspacing="0" cellpadding="0"><tr><td align="right">16.1.1&nbsp;</td><td><a href="#%28part._define-syntax-rule%29" class="tocviewlink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">define-<wbr></wbr>syntax-<wbr></wbr>rule</span></span></span></a></td></tr><tr><td align="right">16.1.2&nbsp;</td><td><a href="#%28part._.Lexical-.Scope%29" class="tocviewlink" data-pltdoc="x">&#35789;&#27861;&#33539;&#22260;</a></td></tr><tr><td align="right">16.1.3&nbsp;</td><td><a href="#%28part._define-syntax-and-syntax-rules%29" class="tocviewlink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">define-<wbr></wbr>syntax</span></span></span>&#21644;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-<wbr></wbr>rules</span></span></span></a></td></tr><tr><td align="right">16.1.4&nbsp;</td><td><a href="#%28part._.Matching-.Sequences%29" class="tocviewlink" data-pltdoc="x">&#21305;&#37197;&#24207;&#21015;</a></td></tr><tr><td align="right">16.1.5&nbsp;</td><td><a href="#%28part._.Identifier-.Macros%29" class="tocviewlink" data-pltdoc="x">&#26631;&#35782;&#31526;&#23439;</a></td></tr><tr><td align="right">16.1.6&nbsp;</td><td><a href="#%28part._set-.Transformers%29" class="tocviewlink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span>&#36716;&#21270;&#22120;</a></td></tr><tr><td align="right">16.1.7&nbsp;</td><td><a href="#%28part._.Macro-.Generating-.Macros%29" class="tocviewlink" data-pltdoc="x">&#23439;&#29983;&#25104;&#23439;</a></td></tr><tr><td align="right">16.1.8&nbsp;</td><td><a href="#%28part._pattern-macro-example%29" class="tocviewlink" data-pltdoc="x">&#25193;&#23637;&#30340;&#20363;&#23376;&#65306;&#20989;&#25968;&#30340;&#24341;&#29992;&#35843;&#29992;</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">16.1.1<tt>&nbsp;</tt></span><a href="#%28part._define-syntax-rule%29" class="tocsubseclink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">define-<wbr></wbr>syntax-<wbr></wbr>rule</span></span></span></a></td></tr><tr><td><span class="tocsublinknumber">16.1.2<tt>&nbsp;</tt></span><a href="#%28part._.Lexical-.Scope%29" class="tocsubseclink" data-pltdoc="x">&#35789;&#27861;&#33539;&#22260;</a></td></tr><tr><td><span class="tocsublinknumber">16.1.3<tt>&nbsp;</tt></span><a href="#%28part._define-syntax-and-syntax-rules%29" class="tocsubseclink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">define-<wbr></wbr>syntax</span></span></span>&#21644;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-<wbr></wbr>rules</span></span></span></a></td></tr><tr><td><span class="tocsublinknumber">16.1.4<tt>&nbsp;</tt></span><a href="#%28part._.Matching-.Sequences%29" class="tocsubseclink" data-pltdoc="x">&#21305;&#37197;&#24207;&#21015;</a></td></tr><tr><td><span class="tocsublinknumber">16.1.5<tt>&nbsp;</tt></span><a href="#%28part._.Identifier-.Macros%29" class="tocsubseclink" data-pltdoc="x">&#26631;&#35782;&#31526;&#23439;</a></td></tr><tr><td><span class="tocsublinknumber">16.1.6<tt>&nbsp;</tt></span><a href="#%28part._set-.Transformers%29" class="tocsubseclink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span>&#36716;&#21270;&#22120;</a></td></tr><tr><td><span class="tocsublinknumber">16.1.7<tt>&nbsp;</tt></span><a href="#%28part._.Macro-.Generating-.Macros%29" class="tocsubseclink" data-pltdoc="x">&#23439;&#29983;&#25104;&#23439;</a></td></tr><tr><td><span class="tocsublinknumber">16.1.8<tt>&nbsp;</tt></span><a href="#%28part._pattern-macro-example%29" class="tocsubseclink" data-pltdoc="x">&#25193;&#23637;&#30340;&#20363;&#23376;&#65306;&#20989;&#25968;&#30340;&#24341;&#29992;&#35843;&#29992;</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><div class="nosearchform"></div>&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a href="macros.html" title="backward to &quot;16 宏&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="macros.html" title="up to &quot;16 宏&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="proc-macros.html" title="forward to &quot;16.2 通用宏转化器&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h4>16.1<tt>&nbsp;</tt><a name="(part._pattern-macros)"></a>&#22522;&#20110;&#27169;&#24335;&#30340;&#23439;</h4><p>&#19968;&#20010;<a name="(tech._~e5~9f~ba~e4~ba~8e~e6~a8~a1~e5~bc~8f~e7~9a~84~e5~ae~8f~ef~bc~88pattern._based._macro~ef~bc~89)"></a><span style="font-style: italic">&#22522;&#20110;&#27169;&#24335;&#30340;&#23439;&#65288;pattern-based macro&#65289;</span>&#23558;&#20219;&#20309;&#19982;&#27169;&#24335;&#21305;&#37197;&#30340;&#20195;&#30721;&#26367;&#25442;&#20026;&#20351;&#29992;&#19982;&#27169;&#24335;&#37096;&#20998;&#21305;&#37197;&#30340;&#21407;&#22987;&#35821;&#27861;&#30340;&#19968;&#37096;&#20998;&#30340;&#25193;&#23637;&#12290;</p><h5>16.1.1<tt>&nbsp;</tt><a name="(part._define-syntax-rule)"></a><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span></h5><p>&#21019;&#24314;&#23439;&#30340;&#26368;&#31616;&#21333;&#26041;&#27861;&#26159;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span>&#65306;</p><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span><span class="hspace">&nbsp;</span><span class="RktVar">pattern</span><span class="hspace">&nbsp;</span><span class="RktVar">template</span><span class="RktPn">)</span></td></tr></table></blockquote></blockquote><p>&#20316;&#20026;&#19968;&#20010;&#36816;&#34892;&#30340;&#20363;&#23376;&#65292;&#32771;&#34385;&#20132;&#25442;&#23439;<span class="RktSym">swap</span>&#65292;&#23427;&#23558;&#20132;&#25442;&#20540;&#23384;&#20648;&#22312;&#20004;&#20010;&#21464;&#37327;&#20013;&#12290;&#21487;&#20197;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span>&#23454;&#29616;&#22914;&#19979;&#65306;</p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>&#23439;&#22312;&#36825;&#20010;&#24847;&#20041;&#19978;&#26159;&#8220;un-Rackety&#8221;&#65292;&#23427;&#28041;&#21450;&#21040;&#21464;&#37327;&#19978;&#30340;&#21103;&#20316;&#29992;&#8212;&#8212;&#20294;&#23439;&#30340;&#37325;&#28857;&#26159;&#35753;&#20320;&#28155;&#21152;&#19968;&#20123;&#20854;&#23427;&#35821;&#35328;&#35774;&#35745;&#24072;&#21487;&#33021;&#19981;&#21516;&#24847;&#30340;&#35821;&#27861;&#34920;&#12290;</p></blockquote></blockquote></blockquote><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span>&#34920;&#32465;&#23450;&#19968;&#20010;&#19982;&#21333;&#20010;&#27169;&#24335;&#21305;&#37197;&#30340;&#23439;&#12290;&#27169;&#24335;&#24517;&#39035;&#24635;&#26159;&#20197;&#19968;&#20010;&#24320;&#25918;&#30340;&#25324;&#21495;&#24320;&#22836;&#65292;&#21518;&#38754;&#36319;&#30528;&#19968;&#20010;&#26631;&#35782;&#31526;&#65292;&#36825;&#20010;&#26631;&#35782;&#31526;&#22312;&#36825;&#20010;&#20363;&#23376;&#20013;&#26159;<span class="RktSym">swap</span>&#12290;&#22312;&#21021;&#22987;&#26631;&#35782;&#31526;&#20043;&#21518;&#65292;&#20854;&#23427;&#26631;&#35782;&#31526;&#26159;<a name="(tech._~e5~ae~8f~e6~a8~a1~e5~bc~8f~e5~8f~98~e9~87~8f~ef~bc~88macro._pattern._variable~ef~bc~89)"></a><span style="font-style: italic">&#23439;&#27169;&#24335;&#21464;&#37327;&#65288;macro pattern variable&#65289;</span>&#65292;&#21487;&#20197;&#21305;&#37197;&#23439;&#20351;&#29992;&#20013;&#30340;&#20219;&#20309;&#20869;&#23481;&#12290;&#22240;&#27492;&#65292;&#36825;&#20010;&#23439;&#21305;&#37197;&#36825;&#20010;&#34920;<span class="RktPn">(</span><span class="RktSym">swap</span><span class="stt"> </span><span class="RktVar">form1</span><span class="stt"> </span><span class="RktVar">form2</span><span class="RktPn">)</span>&#32473;&#20219;&#20309;<span class="RktVar">form1</span>&#21644;<span class="RktVar">form2</span>&#12290;</p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>&#23545;<span class="RktSym">match</span>&#26469;&#35828;&#23439;&#27169;&#24335;&#21464;&#37327;&#19982;&#27169;&#24335;&#21464;&#37327;&#26159;&#31867;&#20284;&#30340;&#12290;&#21442;&#35265;<a href="match.html" data-pltdoc="x">&#27169;&#24335;&#21305;&#37197;</a>&#12290;</p></blockquote></blockquote></blockquote><p>&#22312;<span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span>&#20013;&#30340;&#27169;&#24335;&#20043;&#21518;&#26159;<a name="(tech._~e6~91~b8~e6~9d~bf~ef~bc~88template~ef~bc~89)"></a><span style="font-style: italic">&#25720;&#26495;&#65288;template&#65289;</span>&#12290;&#27169;&#26495;&#29992;&#20110;&#26367;&#20195;&#19982;&#27169;&#24335;&#21305;&#37197;&#30340;&#34920;&#65292;&#20294;&#27169;&#26495;&#20013;&#30340;&#27169;&#24335;&#21464;&#37327;&#30340;&#27599;&#20010;&#23454;&#20363;&#37117;&#26367;&#25442;&#20026;&#23439;&#20351;&#29992;&#27169;&#24335;&#21464;&#37327;&#21305;&#37197;&#30340;&#37096;&#20998;&#12290;&#20363;&#22914;&#65292;&#22312;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">first</span><span class="hspace">&nbsp;</span><span class="RktSym">last</span><span class="RktPn">)</span></p></blockquote><p>&#27169;&#24335;&#21464;&#37327;<span class="RktSym">x</span>&#21305;&#37197;<span class="RktSym">first</span>&#21450;<span class="RktSym">y</span>&#21305;&#37197;<span class="RktSym">last</span>&#65292;&#20110;&#26159;&#25193;&#23637;&#26159;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">first</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">first</span><span class="hspace">&nbsp;</span><span class="RktSym">last</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">last</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><h5>16.1.2<tt>&nbsp;</tt><a name="(part._.Lexical-.Scope)"></a>&#35789;&#27861;&#33539;&#22260;</h5><p>&#20551;&#35774;&#25105;&#20204;&#20351;&#29992;<span class="RktSym">swap</span>&#23439;&#26469;&#20132;&#25442;&#21517;&#20026;<span class="RktSym">tmp</span>&#21644;<span class="RktSym">other</span>&#30340;&#21464;&#37327;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">other</span><span class="hspace">&nbsp;</span><span class="RktVal">6</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">list</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#19978;&#36848;&#34920;&#36798;&#24335;&#30340;&#32467;&#26524;&#24212;&#20026;<span class="RktRes">(6<span class="stt"> </span>5)</span>&#12290;&#28982;&#32780;&#65292;&#36825;&#31181;<span class="RktSym">swap</span>&#30340;&#20351;&#29992;&#30340;&#21333;&#32431;&#25193;&#23637;&#26159;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">other</span><span class="hspace">&nbsp;</span><span class="RktVal">6</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">list</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#20854;&#32467;&#26524;&#26159;<span class="RktRes">(5<span class="stt"> </span>6)</span>&#12290;&#38382;&#39064;&#22312;&#20110;&#65292;&#36825;&#20010;&#21333;&#32431;&#30340;&#25193;&#23637;&#28151;&#28102;&#20102;&#19978;&#19979;&#25991;&#20013;&#30340;<span class="RktSym">tmp</span>&#65292;&#37027;&#37324;<span class="RktSym">swap</span>&#19982;&#23439;&#25720;&#26495;&#20013;&#30340;<span class="RktSym">tmp</span>&#34987;&#20351;&#29992;&#12290;</p><p>Racket&#19981;&#20250;&#20026;&#20102;<span class="RktSym">swap</span>&#30340;&#19978;&#36848;&#20351;&#29992;&#29983;&#25104;&#21333;&#32431;&#30340;&#25193;&#23637;&#12290;&#30456;&#21453;&#65292;&#23427;&#20250;&#29983;&#25104;&#20197;&#19979;&#20869;&#23481;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">other</span><span class="hspace">&nbsp;</span><span class="RktVal">6</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp_1</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp_1</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">list</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#27491;&#30830;&#30340;&#32467;&#26524;&#22312;<span class="RktRes">(6<span class="stt"> </span>5)</span>&#12290;&#21516;&#26679;&#65292;&#22312;&#31034;&#20363;&#20013;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">other</span><span class="hspace">&nbsp;</span><span class="RktVal">6</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">list</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#20854;&#25193;&#23637;&#26159;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">set!_1</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">other</span><span class="hspace">&nbsp;</span><span class="RktVal">6</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp_1</span><span class="hspace">&nbsp;</span><span class="RktSym">set!_1</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">set!_1</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp_1</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">list</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">set!_1</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#22240;&#27492;&#23616;&#37096;<span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span>&#32465;&#23450;&#19981;&#20250;&#24178;&#25200;&#23439;&#27169;&#26495;&#24341;&#20837;&#30340;&#36171;&#20540;&#12290;</p><p>&#25442;&#21477;&#35805;&#35828;&#65292;Racket&#30340;&#22522;&#20110;&#27169;&#24335;&#30340;&#23439;&#33258;&#21160;&#32500;&#25252;&#35789;&#27861;&#33539;&#22260;&#65292;&#25152;&#20197;&#23439;&#30340;&#23454;&#29616;&#32773;&#21487;&#20197;&#24605;&#32771;&#23439;&#20013;&#30340;&#21464;&#37327;&#24341;&#29992;&#20197;&#21450;&#22312;&#21516;&#26679;&#30340;&#36884;&#24452;&#20013;&#20316;&#20026;&#20989;&#25968;&#21644;&#20989;&#25968;&#35843;&#29992;&#30340;&#23439;&#20351;&#29992;&#12290;</p><h5>16.1.3<tt>&nbsp;</tt><a name="(part._define-syntax-and-syntax-rules)"></a><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span>&#21644;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span></h5><p><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span>&#34920;&#32465;&#23450;&#19968;&#20010;&#19982;&#21333;&#19968;&#27169;&#24335;&#21305;&#37197;&#30340;&#23439;&#65292;&#20294;Racket&#30340;&#23439;&#31995;&#32479;&#25903;&#25345;&#20174;&#21516;&#19968;&#26631;&#35782;&#31526;&#24320;&#22987;&#21305;&#37197;&#22810;&#20010;&#27169;&#24335;&#30340;&#36716;&#25442;&#22120;&#12290;&#35201;&#32534;&#20889;&#36825;&#26679;&#30340;&#23439;&#65292;&#31243;&#24207;&#21592;&#24517;&#39035;&#20351;&#29992;&#26356;&#36890;&#29992;&#30340;<span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span>&#34920;&#20197;&#21450;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span>&#36716;&#25442;&#22120;&#34920;&#65306;</p><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktVar">id</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">literal-id</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktVar">pattern</span><span class="hspace">&nbsp;</span><span class="RktVar">template</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></blockquote><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span>&#34920;&#26412;&#36523;&#23601;&#26159;&#19968;&#20010;&#23439;&#65292;&#23427;&#29992;&#19968;&#20010;&#20165;&#21253;&#21547;&#19968;&#20010;&#27169;&#24335;&#21644;&#27169;&#26495;&#30340;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span>&#34920;&#25193;&#23637;&#25104;<span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span>&#12290;</p></blockquote></blockquote></blockquote><p>&#20363;&#22914;&#65292;&#20551;&#35774;&#25105;&#20204;&#24076;&#26395;&#19968;&#20010;<span class="RktSym">rotate</span>&#23439;&#23558;<span class="RktSym">swap</span>&#27010;&#25324;&#20026;&#20004;&#20010;&#25110;&#19977;&#20010;&#26631;&#35782;&#31526;&#65292;&#22240;&#27492;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">red</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">]</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">green</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">]</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">blue</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rotate</span><span class="hspace">&nbsp;</span><span class="RktSym">red</span><span class="hspace">&nbsp;</span><span class="RktSym">green</span><span class="RktPn">)</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">swaps</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rotate</span><span class="hspace">&nbsp;</span><span class="RktSym">red</span><span class="hspace">&nbsp;</span><span class="RktSym">green</span><span class="hspace">&nbsp;</span><span class="RktSym">blue</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">rotates left</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">list</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">red</span><span class="hspace">&nbsp;</span><span class="RktSym">green</span><span class="hspace">&nbsp;</span><span class="RktSym">blue</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#29983;&#25104;<span class="RktRes">(1<span class="stt"> </span>3<span class="stt"> </span>2)</span>&#12290;&#25105;&#20204;&#21487;&#20197;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span>&#23454;&#29616; <span class="RktSym">rotate</span>&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">rotate</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">rotate</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">rotate</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">begin</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#34920;&#36798;&#24335;<span class="RktPn">(</span><span class="RktSym">rotate</span><span class="stt"> </span><span class="RktSym">red</span><span class="stt"> </span><span class="RktSym">green</span><span class="RktPn">)</span>&#19982;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span>&#34920;&#20013;&#30340;&#31532;&#19968;&#20010;&#27169;&#24335;&#30456;&#21305;&#37197;&#65292;&#22240;&#27492;&#25193;&#23637;&#21040;<span class="RktPn">(</span><span class="RktSym">swap</span><span class="stt"> </span><span class="RktSym">red</span><span class="stt"> </span><span class="RktSym">green</span><span class="RktPn">)</span>&#12290;&#34920;&#36798;&#24335;<span class="RktPn">(</span><span class="RktSym">rotate</span><span class="stt"> </span><span class="RktSym">red</span><span class="stt"> </span><span class="RktSym">green</span><span class="stt"> </span><span class="RktSym">blue</span><span class="RktPn">)</span>&#19982;&#31532;&#20108;&#20010;&#27169;&#24335;&#21305;&#37197;&#65292;&#25152;&#20197;&#23427;&#25193;&#23637;&#21040;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">begin</span></span></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="stt"> </span><span class="RktSym">red</span><span class="stt"> </span><span class="RktSym">green</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="stt"> </span><span class="RktSym">green</span><span class="stt"> </span><span class="RktSym">blue</span><span class="RktPn">)</span><span class="RktPn">)</span>&#12290;</p><h5>16.1.4<tt>&nbsp;</tt><a name="(part._.Matching-.Sequences)"></a>&#21305;&#37197;&#24207;&#21015;</h5><p>&#19968;&#20010;&#26356;&#22909;&#30340;<span class="RktSym">rotate</span>&#23439;&#23558;&#20801;&#35768;&#20219;&#24847;&#25968;&#37327;&#30340;&#26631;&#35782;&#31526;&#65292;&#32780;&#19981;&#26159;&#21482;&#26377;&#20004;&#20010;&#25110;&#19977;&#20010;&#26631;&#35782;&#31526;&#12290;&#21305;&#37197;&#20219;&#20309;&#25968;&#37327;&#30340;&#26631;&#35782;&#31526;&#30340;<span class="RktSym">rotate</span>&#20351;&#29992;&#65292;&#25105;&#20204;&#38656;&#35201;&#19968;&#20010;&#27169;&#24335;&#34920;&#65292;&#23427;&#26377;&#28857;&#20687;&#20811;&#26519;&#38381;&#21253;&#65288;Kleene star&#65289;&#12290;&#22312;&#19968;&#20010;Racket&#23439;&#27169;&#24335;&#20013;&#65292;&#19968;&#20010;&#38381;&#21253;&#65288;star&#65289;&#34987;&#20889;&#25104;<span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span>&#12290;</p><p>&#20026;&#20102;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span>&#23454;&#29616;<span class="RktSym">rotate</span>&#65292;&#25105;&#20204;&#38656;&#35201;&#19968;&#20010;&#22522;&#20803;&#65288;base case&#65289;&#26469;&#22788;&#29702;&#21333;&#20010;&#26631;&#35782;&#31526;&#65292;&#20197;&#21450;&#19968;&#20010;&#24402;&#32435;&#26696;&#20363;&#20197;&#22788;&#29702;&#22810;&#20010;&#26631;&#35782;&#31526;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">rotate</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">rotate</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">void</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">rotate</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">begin</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rotate</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#24403;&#22312;&#19968;&#31181;&#27169;&#24335;&#20013;&#20687;<span class="RktSym">c</span>&#36825;&#26679;&#30340;&#27169;&#24335;&#21464;&#37327;&#34987;<span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span>&#36319;&#30528;&#30340;&#26102;&#20505;&#65292;&#23427;&#22312;&#27169;&#26495;&#20013;&#24517;&#39035;&#20063;&#34987;<span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span>&#36319;&#30528;&#12290;&#27169;&#24335;&#21464;&#37327;&#26377;&#25928;&#22320;&#21305;&#37197;&#19968;&#20010;&#38646;&#24207;&#21015;&#25110;&#22810;&#20010;&#34920;&#65292;&#24182;&#22312;&#27169;&#26495;&#20013;&#20197;&#30456;&#21516;&#30340;&#39034;&#24207;&#34987;&#26367;&#25442;&#12290;</p><p>&#21040;&#30446;&#21069;&#20026;&#27490;&#65292;<span class="RktSym">rotate</span>&#30340;&#20004;&#31181;&#29256;&#26412;&#37117;&#26377;&#28857;&#25928;&#29575;&#20302;&#19979;&#65292;&#22240;&#20026;&#25104;&#23545;&#20132;&#25442;&#24635;&#26159;&#23558;&#31532;&#19968;&#20010;&#21464;&#37327;&#30340;&#20540;&#31227;&#21160;&#21040;&#24207;&#21015;&#20013;&#30340;&#27599;&#20010;&#21464;&#37327;&#65292;&#30452;&#21040;&#36798;&#21040;&#26368;&#21518;&#19968;&#20010;&#21464;&#37327;&#20026;&#27490;&#12290;&#26356;&#26377;&#25928;&#30340;<span class="RktSym">rotate</span>&#23558;&#31532;&#19968;&#20010;&#20540;&#30452;&#25509;&#31227;&#21160;&#21040;&#26368;&#21518;&#19968;&#20010;&#21464;&#37327;&#12290;&#25105;&#20204;&#21487;&#20197;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span>&#27169;&#24335;&#20351;&#29992;&#36741;&#21161;&#23439;&#21435;&#23454;&#29616;&#26356;&#26377;&#25928;&#30340;&#21464;&#20307;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">rotate</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">rotate</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">shift-to</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">shift-to</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">shift-to</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">from0</span><span class="hspace">&nbsp;</span><span class="RktSym">from</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">to0</span><span class="hspace">&nbsp;</span><span class="RktSym">to</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktSym">from0</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">to</span><span class="hspace">&nbsp;</span><span class="RktSym">from</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">to0</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#22312;<span class="RktSym">shift-to</span>&#23439;&#37324;&#65292;&#22312;&#27169;&#26495;&#37324;&#30340;<span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span>&#21518;&#38754;&#36319;&#30528;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="stt"> </span><span class="RktSym">to</span><span class="stt"> </span><span class="RktSym">from</span><span class="RktPn">)</span>&#65292;&#23427;&#23548;&#33268;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="stt"> </span><span class="RktSym">to</span><span class="stt"> </span><span class="RktSym">from</span><span class="RktPn">)</span>&#34920;&#36798;&#24335;&#22312;<span class="RktSym">to</span>&#21644;<span class="RktSym">from</span>&#24207;&#21015;&#20013;&#19982;&#24517;&#39035;&#20351;&#29992;&#30340;&#27599;&#20010;&#26631;&#35782;&#31526;&#21305;&#37197;&#34987;&#22797;&#21046;&#19968;&#26679;&#22810;&#27425;&#12290;&#65288;<span class="RktSym">to</span>&#21644;<span class="RktSym">from</span>&#21305;&#37197;&#30340;&#25968;&#37327;&#24517;&#39035;&#30456;&#21516;&#65292;&#21542;&#21017;&#23439;&#25193;&#23637;&#23601;&#20250;&#26377;&#19968;&#20010;&#38169;&#35823;&#30340;&#22833;&#36133;&#12290;&#65289;</p><h5>16.1.5<tt>&nbsp;</tt><a name="(part._.Identifier-.Macros)"></a>&#26631;&#35782;&#31526;&#23439;</h5><p>&#26681;&#25454;&#25105;&#20204;&#30340;&#23439;&#23450;&#20041;&#65292;<span class="RktSym">swap</span>&#25110;<span class="RktSym">rotate</span>&#26631;&#35782;&#31526;&#24517;&#39035;&#22312;&#24320;&#25324;&#21495;&#20043;&#21518;&#20351;&#29992;&#65292;&#21542;&#21017;&#20250;&#25253;&#21578;&#35821;&#27861;&#38169;&#35823;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">eval:2:0: swap: bad syntax</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: swap</span></p></td></tr></table></blockquote><p>&#19968;&#20010;<a name="(tech._~e6~a0~87~e8~af~86~e7~ac~a6~e5~ae~8f~ef~bc~88identifier._macro~ef~bc~89)"></a><span style="font-style: italic">&#26631;&#35782;&#31526;&#23439;&#65288;identifier macro&#65289;</span>&#26159;&#19968;&#20010;&#27169;&#24335;&#21305;&#37197;&#23439;&#65292;&#24403;&#23427;&#34987;&#33258;&#24049;&#20351;&#29992;&#26102;&#19981;&#20351;&#29992;&#25324;&#21495;&#12290;&#20363;&#22914;&#65292;&#25105;&#20204;&#21487;&#20197;&#23450;&#20041;<span class="RktSym">val</span>&#20026;&#19968;&#20010;&#26631;&#35782;&#31526;&#23439;&#65292;&#25193;&#23637;&#21040;<span class="RktPn">(</span><span class="RktSym">get-val</span><span class="RktPn">)</span>&#65292;&#25152;&#20197;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="stt"> </span><span class="RktSym">val</span><span class="stt"> </span><span class="RktVal">3</span><span class="RktPn">)</span>&#23558;&#25193;&#23637;&#21040;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">get-val</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktVal">3</span><span class="RktPn">)</span>&#12290;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-case</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">val</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">identifier?</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">get-val</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-values</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">get-val</span><span class="hspace">&nbsp;</span><span class="RktSym">put-val!</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">private-val</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">values</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">private-val</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">private-val</span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktSym">val</span></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr></table></blockquote><p><span class="RktSym">val</span>&#23439;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-case</span></span></span>&#65292;&#23427;&#21487;&#20197;&#23450;&#20041;&#26356;&#24378;&#22823;&#30340;&#23439;&#65292;&#24182;&#22312;&#12298;<a href="syntax-case.html" data-pltdoc="x">&#28151;&#21512;&#27169;&#24335;&#21644;&#34920;&#36798;&#24335;&#65306;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-case</span></span></span></a>&#12299;&#20013;&#35762;&#35299;&#12290;&#29616;&#22312;&#65292;&#30693;&#36947;&#23450;&#20041;&#23439;&#26159;&#24517;&#35201;&#30340;&#65292;&#22312;<span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span>&#20013;&#20351;&#29992;&#20102;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-case</span></span></span>&#65292;&#23427;&#30340;&#27169;&#26495;&#24517;&#39035;&#29992;&#26174;&#24335;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span>&#26500;&#36896;&#22120;&#21253;&#35013;&#12290;&#26368;&#21518;&#65292;<span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-case</span></span></span>&#23376;&#21477;&#21487;&#20197;&#25351;&#23450;&#27169;&#24335;&#21518;&#38754;&#30340;&#38468;&#21152;&#20445;&#25252;&#26465;&#20214;&#12290;</p><p>&#25105;&#20204;&#30340;<span class="RktSym">val</span>&#23439;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">identifier?</span></span></span>&#26465;&#20214;&#30830;&#20445;&#22312;&#25324;&#21495;&#20013;<span class="RktSym">val</span><span style="font-style: italic">&#19981;&#33021;&#65288;must not&#65289;</span>&#20351;&#29992;&#12290;&#30456;&#21453;&#65292;&#23439;&#24341;&#19968;&#20010;&#21457;&#35821;&#27861;&#38169;&#35823;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">val</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">eval:8:0: val: bad syntax</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: (val)</span></p></td></tr></table></blockquote><h5>16.1.6<tt>&nbsp;</tt><a name="(part._set-.Transformers)"></a><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span>&#36716;&#21270;&#22120;</h5><p>&#20351;&#29992;&#19978;&#38754;&#30340;<span class="RktSym">val</span>&#23439;&#65292;&#25105;&#20204;&#20173;&#28982;&#24517;&#39035;&#35843;&#29992;<span class="RktSym">put-val!</span>&#26356;&#25913;&#23384;&#20648;&#20540;&#12290;&#28982;&#32780;&#65292;&#30452;&#25509;&#22312;<span class="RktSym">val</span>&#19978;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span>&#20250;&#26356;&#26041;&#20415;&#12290;&#24403;<span class="RktSym">val</span>&#29992;&#20110;<span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span>&#26102;&#20511;&#21161;&#23439;&#65292;&#25105;&#20204;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">make-set!-transformer</span></span></span>&#21019;&#24314;&#19968;&#20010;<font class="badlink"><span class="techoutside"><span class="techinside">&#36171;&#20540;&#36716;&#25442;&#22120;&#65288;assignment transformer&#65289;</span></span></font>&#12290;&#25105;&#20204;&#36824;&#24517;&#39035;&#22768;&#26126;set!&#20316;&#20026;syntax-case&#25991;&#26412;&#21015;&#34920;&#20013;&#30340;&#25991;&#23383;&#12290;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val2</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">make-set!-transformer</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-case</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">val2</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">identifier?</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val2</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">get-val</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val2</span><span class="hspace">&nbsp;</span><span class="RktSym">e</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">put-val!</span><span class="hspace">&nbsp;</span><span class="RktSym">e</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktSym">val2</span></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val2</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val2</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktSym">val2</span></td></tr><tr><td><p><span class="RktRes">10</span></p></td></tr></table></blockquote><h5>16.1.7<tt>&nbsp;</tt><a name="(part._.Macro-.Generating-.Macros)"></a>&#23439;&#29983;&#25104;&#23439;</h5><p>&#20551;&#35774;&#25105;&#20204;&#26377;&#35768;&#22810;&#26631;&#35782;&#31526;&#20687;<span class="RktSym">val</span>&#21644;<span class="RktSym">val2</span>&#65292;&#25105;&#20204;&#24819;&#37325;&#23450;&#21521;&#32473;&#35775;&#38382;&#22120;&#21644;&#31361;&#21464;&#20989;&#25968;&#20687;<span class="RktSym">get-val</span>&#21644;<span class="RktSym">put-val!</span>&#12290;&#25105;&#20204;&#24076;&#26395;&#21487;&#20197;&#21482;&#20889;&#65306;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym">define-get/put-id</span><span class="hspace">&nbsp;</span><span class="RktSym">val</span><span class="hspace">&nbsp;</span><span class="RktSym">get-val</span><span class="hspace">&nbsp;</span><span class="RktSym">put-val!</span><span class="RktPn">)</span></p></blockquote><p>&#33258;&#28982;&#22320;&#65292;&#25105;&#20204;&#21487;&#20197;&#23454;&#29616;<span class="RktSym">define-get/put-id</span>&#20026;&#19968;&#20010;&#23439;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-get/put-id</span><span class="hspace">&nbsp;</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym">get</span><span class="hspace">&nbsp;</span><span class="RktSym">put!</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">id</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">make-set!-transformer</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-case</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">identifier?</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">id</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">get</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym">e</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">put!</span><span class="hspace">&nbsp;</span><span class="RktSym">e</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">define-get/put-id</span><span class="hspace">&nbsp;</span><span class="RktSym">val3</span><span class="hspace">&nbsp;</span><span class="RktSym">get-val</span><span class="hspace">&nbsp;</span><span class="RktSym">put-val!</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">val3</span><span class="hspace">&nbsp;</span><span class="RktVal">11</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktSym">val3</span></td></tr><tr><td><p><span class="RktRes">11</span></p></td></tr></table></blockquote><p>&#33258;&#28982;&#22320;&#65292;&#25105;&#20204;&#21487;&#20197;&#23454;&#29616;<span class="RktSym">define-get/put-id</span>&#20026;&#19968;&#20010;&#23439;&#65306;</p><h5>16.1.8<tt>&nbsp;</tt><a name="(part._pattern-macro-example)"></a>&#25193;&#23637;&#30340;&#20363;&#23376;&#65306;&#20989;&#25968;&#30340;&#24341;&#29992;&#35843;&#29992;</h5><p>&#25105;&#20204;&#21487;&#20197;&#20351;&#29992;&#27169;&#24335;&#21305;&#37197;&#23439;&#23558;&#19968;&#20010;&#34920;&#28155;&#21152;&#21040;Racket&#20013;&#65292;&#20197;&#23450;&#20041;<a name="(tech._~e5~bc~95~e7~94~a8~e8~b0~83~e7~94~a8~e5~87~bd~e6~95~b0~ef~bc~88call._by._reference._function~ef~bc~89)"></a><span style="font-style: italic">&#24341;&#29992;&#35843;&#29992;&#20989;&#25968;&#65288;call-by-reference function&#65289;</span>&#30340;&#19968;&#38454;&#35843;&#29992;&#12290;&#24403;&#36890;&#36807;&#21442;&#32771;&#20989;&#25968;&#26412;&#20307;&#36716;&#21464;&#23427;&#30340;&#27491;&#24335;&#21442;&#25968;&#65292;&#36825;&#20010;&#36716;&#21464;&#24212;&#29992;&#21040;&#21464;&#37327;&#65292;&#23427;&#22312;&#23545;&#20989;&#25968;&#30340;&#35843;&#29992;&#20013;&#20316;&#20026;&#19968;&#20010;&#23454;&#21442;&#25552;&#20379;&#12290;</p><p>&#20363;&#22914;&#65292;&#22914;&#26524;<span class="RktSym">define-cbr</span>&#31867;&#20284;&#20110;<span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span>&#65292;&#38500;&#20102;&#23450;&#20041;&#24212;&#29992;&#35843;&#29992;&#20989;&#25968;&#65292;&#37027;&#20040;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym">define-cbr</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">]</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">y</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">list</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#29983;&#25104;<span class="RktRes">(2<span class="stt"> </span>1)</span>&#12290;</p><p>&#25105;&#20204;&#20250;&#36890;&#36807;&#26377;&#20989;&#25968;&#35843;&#29992;&#25903;&#25345;&#30340;&#23545;&#21442;&#25968;&#30340;&#35775;&#38382;&#22120;&#21644;&#36716;&#25442;&#22120;&#25191;&#34892;&#21442;&#32771;&#20989;&#25968;&#65292;&#32780;&#19981;&#26159;&#30452;&#25509;&#25552;&#20379;&#21442;&#25968;&#20540;&#12290;&#29305;&#21035;&#26159;&#65292;&#23545;&#20110;&#19978;&#38754;&#30340;&#20989;&#25968;<span class="RktSym">f</span>&#65292;&#25105;&#20204;&#23558;&#29983;&#25104;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktSym">get-a</span><span class="hspace">&nbsp;</span><span class="RktSym">get-b</span><span class="hspace">&nbsp;</span><span class="RktSym">put-a!</span><span class="hspace">&nbsp;</span><span class="RktSym">put-b!</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-get/put-id</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">get-a</span><span class="hspace">&nbsp;</span><span class="RktSym">put-a!</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-get/put-id</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktSym">get-b</span><span class="hspace">&nbsp;</span><span class="RktSym">put-b!</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#24182;&#23558;&#20989;&#25968;&#35843;&#29992;<span class="RktPn">(</span><span class="RktSym">f</span><span class="stt"> </span><span class="RktSym">x</span><span class="stt"> </span><span class="RktSym">y</span><span class="RktPn">)</span>&#37325;&#23450;&#21521;&#21040;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#26174;&#28982;&#65292;&#28982;&#21518;<span class="RktSym">define-cbr</span>&#26159;&#23439;&#29983;&#25104;&#23439;&#65292;&#32465;&#23450;<span class="RktSym">f</span>&#21040;&#19968;&#20010;&#23439;&#65292;&#23427;&#25193;&#23637;&#21040;<span class="RktSym">do-f</span>&#30340;&#19968;&#20010;&#35843;&#29992;&#12290;&#21363;<span class="RktPn">(</span><span class="RktSym">define-cbr</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">f</span><span class="stt"> </span><span class="RktSym">a</span><span class="stt"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="stt"> </span><span class="RktSym">a</span><span class="stt"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span>&#38656;&#35201;&#29983;&#25104;&#30340;&#23450;&#20041;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">f</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym">actual</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">actual</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">actual</span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#21516;&#26102;&#65292;<span class="RktSym">define-cbr</span>&#38656;&#35201;&#20351;&#29992;<span class="RktSym">f</span>&#26412;&#20307;&#21435;&#23450;&#20041;<span class="RktSym">do-f</span>&#65292;&#31532;&#20108;&#37096;&#20998;&#26159;&#30053;&#24494;&#26356;&#22797;&#26434;&#20123;&#65292;&#25152;&#20197;&#25105;&#20204;&#24310;&#36831;&#23427;&#30340;&#22823;&#37096;&#20998;&#32473;&#19968;&#20010;<span class="RktSym">define-for-cbr</span>&#36741;&#21161;&#27169;&#22359;&#65292;&#23427;&#21487;&#20197;&#35753;&#25105;&#20204;&#36275;&#22815;&#31616;&#21333;&#22320;&#32534;&#20889;<span class="RktSym">define-cbr</span>&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax-rule</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-cbr</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym">arg</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">body</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">begin</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">id</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym">actual</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">actual</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">lambda</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">actual</span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-for-cbr</span><span class="hspace">&nbsp;</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">arg</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#19979;&#38754;&#30340;&#35299;&#37322;&#8230;&#8230;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">body</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#25105;&#20204;&#21097;&#19979;&#30340;&#20219;&#21153;&#26159;&#23450;&#20041;<span class="RktSym">define-for-cbr</span>&#20197;&#20415;&#23427;&#36716;&#25442;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym">define-for-cbr</span><span class="hspace">&nbsp;</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote><p>&#21040;&#19978;&#36793;&#30340;&#36825;&#20010;&#20989;&#25968;&#23450;&#20041;<span class="RktSym">do-f</span>&#20004;&#20010;&#21151;&#33021;&#23450;&#20041;&#12290;&#22823;&#37096;&#20998;&#30340;&#24037;&#20316;&#26159;&#29983;&#25104;&#19968;&#20010;<span class="RktSym">define-get/put-id</span>&#22768;&#26126;&#32473;&#27599;&#20010;&#21442;&#25968;&#65292;<span class="RktSym">a</span>&#21644;<span class="RktSym">b</span>&#65292;&#20197;&#21450;&#25226;&#20182;&#20204;&#25918;&#22312;&#26412;&#20307;&#20043;&#21069;&#12290;&#36890;&#24120;&#65292;&#23545;&#20110;&#22312;&#27169;&#24335;&#21644;&#27169;&#26495;&#20013;&#30340;<span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span>&#37027;&#26159;&#24456;&#23481;&#26131;&#30340;&#20219;&#21153;&#65292;&#20294;&#36825;&#27425;&#36825;&#37324;&#26377;&#19968;&#20010;&#25429;&#33719;&#65306;&#25105;&#20204;&#38656;&#35201;&#26082;&#29983;&#25104;&#36825;&#20010;&#21517;&#23383;<span class="RktSym">get-a</span>&#21644;<span class="RktSym">put-a!</span>&#20063;&#35201;&#29983;&#25104;<span class="RktSym">get-b</span>&#21644;<span class="RktSym">put-b!</span>&#65292;&#36825;&#20010;&#27169;&#24335;&#35821;&#35328;&#27809;&#26377;&#21150;&#27861;&#25552;&#20379;&#22522;&#20110;&#29616;&#26377;&#26631;&#35782;&#31526;&#30340;&#32508;&#21512;&#26631;&#35782;&#31526;&#12290;</p><p>&#20107;&#23454;&#35777;&#26126;&#65292;&#35789;&#27861;&#33539;&#22260;&#32473;&#20102;&#25105;&#20204;&#35299;&#20915;&#36825;&#20010;&#38382;&#39064;&#30340;&#26041;&#27861;&#12290;&#35776;&#31373;&#26159;&#20026;&#20989;&#25968;&#20013;&#30340;&#27599;&#20010;&#21442;&#25968;&#36845;&#20195;&#19968;&#27425;&#23545;<span class="RktSym">define-for-cbr</span>&#30340;&#25193;&#23637;&#65292;&#36825;&#23601;&#26159;&#20026;&#20160;&#20040;<span class="RktSym">define-for-cbr</span>&#24320;&#22987;&#29992;&#19968;&#20010;&#22312;&#21442;&#25968;&#21015;&#34920;&#21518;&#38754;&#26126;&#26174;&#26080;&#25928;&#30340;<span class="RktPn">(</span><span class="RktPn">)</span>&#30340;&#21407;&#22240;&#12290;&#38500;&#20102;&#35201;&#22788;&#29702;&#30340;&#21442;&#25968;&#22806;&#65292;&#25105;&#20204;&#36824;&#38656;&#35201;&#36319;&#36394;&#36804;&#20170;&#20026;&#27490;&#25152;&#30475;&#21040;&#30340;&#25152;&#26377;&#21442;&#25968;&#20197;&#21450;&#20026;&#27599;&#20010;&#29983;&#25104;&#30340;<span class="RktSym">get</span>&#21644;<span class="RktSym">put</span>&#21517;&#31216;&#12290;&#22312;&#22788;&#29702;&#23436;&#25152;&#26377;&#30340;&#26631;&#35782;&#31526;&#20043;&#21518;&#65292;&#25105;&#20204;&#23601;&#25317;&#26377;&#20102;&#25152;&#26377;&#38656;&#35201;&#30340;&#21517;&#31216;&#12290;</p><p>&#36825;&#37324;&#26159;<span class="RktSym">define-for-cbr</span>&#30340;&#23450;&#20041;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define-syntax</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">define-for-cbr</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">syntax-rules</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">define-for-cbr</span><span class="hspace">&nbsp;</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">id0</span><span class="hspace">&nbsp;</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">gens</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">body</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-for-cbr</span><span class="hspace">&nbsp;</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">gens</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">id0</span><span class="hspace">&nbsp;</span><span class="RktSym">get</span><span class="hspace">&nbsp;</span><span class="RktSym">put</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">body</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">define-for-cbr</span><span class="hspace">&nbsp;</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym">get</span><span class="hspace">&nbsp;</span><span class="RktSym">put</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">body</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktSym">get</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">put</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-get/put-id</span><span class="hspace">&nbsp;</span><span class="RktSym">id</span><span class="hspace">&nbsp;</span><span class="RktSym">get</span><span class="hspace">&nbsp;</span><span class="RktSym">put</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">...</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">body</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#19968;&#27493;&#19968;&#27493;&#65292;&#23637;&#24320;&#22914;&#19979;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym">define-for-cbr</span><span class="hspace">&nbsp;</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">=&gt;</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-for-cbr</span><span class="hspace">&nbsp;</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">b</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">get_1</span><span class="hspace">&nbsp;</span><span class="RktSym">put_1</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">=&gt;</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-for-cbr</span><span class="hspace">&nbsp;</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">get_1</span><span class="hspace">&nbsp;</span><span class="RktSym">put_1</span><span class="RktPn">]</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktSym">get_2</span><span class="hspace">&nbsp;</span><span class="RktSym">put_2</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">=&gt;</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktSym">get_1</span><span class="hspace">&nbsp;</span><span class="RktSym">get_2</span><span class="hspace">&nbsp;</span><span class="RktSym">put_1</span><span class="hspace">&nbsp;</span><span class="RktSym">put_2</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-get/put-id</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">get_1</span><span class="hspace">&nbsp;</span><span class="RktSym">put_1</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-get/put-id</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktSym">get_2</span><span class="hspace">&nbsp;</span><span class="RktSym">put_2</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">swap</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#22312;<span class="RktSym">get_1</span>&#12289;<span class="RktSym">get_2</span>&#12289;<span class="RktSym">put_1</span>&#21644;<span class="RktSym">put_2</span>&#19978;&#30340;&#8220;&#19979;&#26631;&#65288;subscript&#65289;&#8221;&#36890;&#36807;&#23439;&#25193;&#23637;&#25554;&#20837;&#21040;&#20445;&#30041;&#35789;&#27861;&#33539;&#22260;&#65292;&#22240;&#20026;<span class="RktSym">get</span>&#34987;<span class="RktSym">define-for-cbr</span>&#30340;&#27599;&#19968;&#27425;&#36845;&#20195;&#29983;&#25104;&#19981;&#24212;&#25414;&#32465;&#34987;&#19981;&#21516;&#30340;&#36845;&#20195;&#29983;&#25104;&#30340;<span class="RktSym">get</span>&#12290;&#25442;&#21477;&#35805;&#35828;&#65292;&#25105;&#20204;&#26412;&#36136;&#19978;&#27450;&#39575;&#36825;&#20010;&#23439;&#25193;&#23637;&#20197;&#29983;&#25104;&#30340;&#25105;&#20204;&#26032;&#30340;&#21517;&#23383;&#65292;&#20294;&#25216;&#26415;&#26174;&#31034;&#20102;&#19968;&#20123;&#19982;&#33258;&#21160;&#35789;&#27861;&#33539;&#22260;&#30340;&#23439;&#27169;&#24335;&#30340;&#31070;&#22855;&#21147;&#37327;&#12290;</p><p>&#26368;&#21518;&#34920;&#36798;&#24335;&#26368;&#32456;&#25193;&#23637;&#25104;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">do-f</span><span class="hspace">&nbsp;</span><span class="RktSym">get_1</span><span class="hspace">&nbsp;</span><span class="RktSym">get_2</span><span class="hspace">&nbsp;</span><span class="RktSym">put_1</span><span class="hspace">&nbsp;</span><span class="RktSym">put_2</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">let</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">tmp</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">get_1</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">put_1</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">get_2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">put_2</span><span class="hspace">&nbsp;</span><span class="RktSym">tmp</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#23427;&#23454;&#29616;&#20102;&#21517;&#31216;&#35843;&#29992;&#65288;call-by-name&#65289;&#20989;&#25968;<span class="RktSym">f</span>&#12290;</p><p>&#25509;&#19979;&#26469;&#65292;&#24635;&#32467;&#19968;&#19979;&#65292;&#25105;&#20204;&#21487;&#20197;&#21482;&#29992;&#19977;&#20010;&#22522;&#20110;&#27169;&#24335;&#30340;&#23439;&#28155;&#21152;&#24341;&#29992;&#35843;&#29992;&#65288;call-by-reference&#65289;&#20989;&#25968;&#21040;Racket&#20013;&#65306;<span class="RktSym">define-cbr</span>&#12289;<span class="RktSym">define-for-cbr</span>&#21644;<span class="RktSym">define-get/put-id</span>&#12290;</p><div class="navsetbottom"><span class="navleft"><div class="nosearchform"></div>&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a href="macros.html" title="backward to &quot;16 宏&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="macros.html" title="up to &quot;16 宏&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="proc-macros.html" title="forward to &quot;16.2 通用宏转化器&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>